package n14.second;

import java.util.*;

public class S02 {

	public static void main(String[] args) {
        List<Student> list = new ArrayList<>();
        list.add(new Student("张三", 85, "一班"));
        list.add(new Student("李四", 90, "二班"));
        list.add(new Student("王五", 78, "一班"));
        list.add(new Student("赵六", 88, "三班"));
        list.add(new Student("孙七", 92, "二班"));
        System.out.println("显示一班的所有学生信息");
        list.stream().filter(s->s.getClassName().equals("一班")).forEach(System.out::println);
        System.out.println("显示一班的所有学生的总成绩");
        Integer sum1 = list.stream().filter(s->s.getClassName().equals("一班"))
        	.reduce(0, (sum,student)->sum+student.getScore(), (s1,s2)->s1+s2);
        System.out.println(sum1);
        System.out.println("一班所有同学成绩最高的学生信息");
        list.stream().filter(s->s.getClassName().equals("一班"))
        	.max(Comparator.comparingInt(s->s.getScore()))
        	.ifPresent(System.out::println);
        
	}

}
